import { http } from "@/util/request/index";

// 订单列表
export const orderList = (params) => {
  return http.get("/api/sales/", {
    params,
  });
};

// 创建订单
export const addOrder = (params) => {
  return http.post("/api/sales/create/", params);
};

// 订单详情
export const orderDetail = (id) => {
  return http.get(`/api/sales/${id}/`);
};

// 创建支付订单
export const addPayOrder = (id) => {
  return http.post(`/api/sales/${id}/payment/`);
};

// 微信小程序支付
export const wechatPayInfo = (params) => {
  return http.post("/api/wx/pay/weapp/", params);
};

// 取消微信支付订单
export const cancelWechatPayOrder = (params) => {
  return http.post("/api/payment/cancel/", params);
};

// 订单取消
export const cancelOrder = (id) => {
  return http.post(`/api/sales/${id}/cancel/`);
};

// 申请售后
export const applyAftercare = (payload) => {
  return http.post(`/api/sales/${payload.id}/service/`, payload);
};

// 售后订单列表
export const aftercareList = (params) => {
  return http.get("/api/sales/services/", { params });
};

// 售后订单详情
export const aftercareDetail = (id) => {
  return http.get(`/api/sales/services/${id}/`);
};

// 取消售后
export const cancelAftercare = (id) => {
  return http.delete(`/api/sales/services/${id}/`);
};

// 历史订单
export const orderHistory = (params) => {
  return http.get("/api/sales/history/products/", { params });
};

// 支付订单状态查询
export const payOrderStatus = (params) => {
  return http.post("/api/payment/status/", params);
};

// 预下单
export const beforeCreateOrder = (params) => {
  return http.post("/api/sales/prepare/", params);
};
